<%@ page import="com.cloudstore.dev.api.util.HttpManager" %>
<%@ page import="org.apache.commons.codec.binary.Base64" %>
<%@ page import="weaver.conn.RecordSet" %>
<%@ page import="weaver.general.BaseBean" %>
<%@ page import="weaver.general.Util" %>
<%@ page import="weaver.system.SystemComInfo" %>
<%@ page import="java.util.HashMap" %>
<%@ page import="java.util.Map" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
<%
    BaseBean bb = new BaseBean();
    String tokenUrl = "";
    try {
        //User user = HrmUserVarify.getUser(request, response);
        String loginid = Util.null2String(request.getParameter("loginid"));
        String bsid = Util.null2String(request.getParameter("bsid"));
        String urlParam = Util.null2String(request.getParameter("url"));
        out.print(">>>>>singleponint.jsp>>>>>bsid=" + bsid + ";urlParam=" + urlParam+"<br/>");
        RecordSet rs = new RecordSet();
        rs.executeQuery("select appid,dz from uf_ddjcpz where id =?", bsid);
        rs.next();
        String appid = Util.null2String(rs.getString("appid"));
        String dz = Util.null2String(rs.getString("dz"));
        out.print("---singleponint.jsp---appid=" + appid + ";dz=" + dz+"<br/>");
        if(!"".equals(appid) && !"".equals(dz)){
            String oaaddress = new SystemComInfo().getOaaddress();
            out.print("---singleponint.jsp---oaaddress=" + oaaddress+"<br/>");
            Map<String, String> map = new HashMap<>();
            map.put("appid", appid);
            map.put("loginid", loginid);
            String OAUrl = oaaddress + "/ssologin/getToken";
            HttpManager httpManager = new HttpManager();
            out.print(">>>>>singleponint.jsp>>>>OAUrl=" + OAUrl+"<br/>");
            String token = Util.null2String(httpManager.getData(OAUrl, map));
            out.print(">>>>>singleponint.jsp>>>>token=" + token+"<br/>");
            if (!urlParam.equals("")) {
                Base64 base64 = new Base64();
                urlParam = new String(base64.decode(urlParam.getBytes()), "UTF-8");
                dz = dz + urlParam;
            } else {
                if (!"".equals(token)) {
                    if (dz.contains("?")) {
                        dz = dz + "&token=" + token;
                    } else {
                        dz = dz + "?token=" + token;
                    }
                }
            }
            out.print(">>>>>singleponint.jsp>>>>newdz=" + dz+"<br/>");
        }
        tokenUrl = dz;
        //response.sendRedirect(dz);
    } catch (Exception e) {
        bb.writeLog("---singleponint.jsp error=", e);
    }
%>
<script type="javascript">
    var url = <%=tokenUrl%>;
    alert("跳转地址");
    window.location.href = url;
</script>